﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kugar.Core.Security.Permission
{
    /// <summary>
    ///     操作权限信息
    /// </summary>
    public class PermissionOperation
    {
        public string ActionName;

        public bool IsEnabled;

        public string Description;

        public string CategoryName;

        public PermissionOperation ParentAction;

        public PermissionOperation Copy()
        {
            var s = new PermissionOperation();

            s.ActionName = this.ActionName;
            s.IsEnabled = this.IsEnabled;
            s.Description = this.Description;
            s.CategoryName = this.CategoryName;
            s.ParentAction = this.ParentAction;

            return s;
        }
    }

    /// <summary>
    ///     数据操作权限
    /// </summary>
    public class PermissionDataOperation:PermissionOperation
    {
        public string Data;
    }

    /// <summary>
    ///     指定函数或者属性操作所需的权限
    /// </summary>
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property,AllowMultiple = true,Inherited = true)]
    public class Permission:Attribute
    {
        public Permission(params string[] actionNames)
        {
            ActionNames = actionNames;
        }

        public string[] ActionNames { get; private set; }
    }

    //public class PermissionDataInfoAttriubte : PermissionOperationInfoAttribute
    //{
    //    public static PermissionInfoGetterBase PermisionInfoGetter { set; get; }
    //}
}
